import { Component, lazy } from "react";
import { createBrowserRouter, createHashRouter } from "react-router";
import App from "./views/Layout";
import Layout from "./App";
import Coupon from "./views/Coupon";
// import Home from './views/Home'
import Manage from "./views/Manage";
import Analysis from "./views/Analysis";
import Promotion from "./views/Promotion";
// 本质：promise
const Home = import("./views/Home");
// 路由定义 map
const routes = [
  {
    path: "/",
    Component: Layout,
    children: [
      {
        path: '/',
        Component: App,
        children: [
          {
            path: "home",
            Component: lazy(() => Home),
          },
          {
            path: "manage",
            element: <Manage />,
          },
          {
            path: "analysis",
            Component: Analysis,
          },
          {
            path: "promotion",
            Component: Promotion,
          },
        ],
      },
      {
        path: 'member-care',
        Component: lazy(() => import('@/views/MemberCare'))
      },
      {
        path: 'member-list',
        Component: lazy(() => import('@/views/MemberList'))
      },
      {
        path: 'pro-filter',
        Component: lazy(() => import('@/views/ProFilter'))
      },
      {
        path: 'coupon',
        Component: Coupon
      },
      {
        path: "*",
        Component: () => <h1>404</h1>,
      },
    ],
  },
];

export default createHashRouter(routes);
